package com.wanlian.json;

import com.wanlian.model.ResultModel;

/**
 * 各种json形式的返回
 *
 * @author lenovo
 */
public class JsonResult {
    public String Serailze(ResultModel resultModel) {
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String Serailze(String message) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(true);
        resultModel.setMessage(message);
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String Serailze(Boolean bresult) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(bresult);
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String Serailze(Object object) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(true);
        resultModel.setObject(object);
        return JsonStringUtil.writeValueAsString(resultModel);
    }
    public String Serailze(Object object,long count) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(true);
        resultModel.setCount(count);
        resultModel.setObject(object);
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String Serailze(boolean result, int errorTag, String message) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(result);
        resultModel.setErrorTag(errorTag);
        resultModel.setMessage(message);
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String Serailze(boolean result, String message) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(result);
        resultModel.setMessage(message);
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String Serailze(boolean result, String message, Object object) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(result);
        resultModel.setMessage(message);
        resultModel.setObject(object);
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String Serailze(boolean result, String message, Object object,
                           String url) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(result);
        resultModel.setMessage(message);
        resultModel.setObject(object);
        resultModel.setUrl(url);
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String SerailzeUrl(String url) {
        ResultModel resultModel = new ResultModel();
        resultModel.setBresult(true);
        resultModel.setUrl(url);
        return JsonStringUtil.writeValueAsString(resultModel);
    }

    public String SerailzeObject(Object object){
        return JsonStringUtil.writeValueAsString(object);
    }

}
